package service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import entity.LayRequest;
import entity.Users;
import mapper.UsersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Administrator
 * @create 2020.06.18 下午 12:09
 */
@Service
public class UsersServiceImpl implements UsersService {
@Autowired
private UsersMapper usersMapper;
    @Override
    public PageInfo<Users> selectByMap(LayRequest layRequest) {
        //1.设置当前页和每页记录数
        PageHelper.startPage(layRequest.getPage(),layRequest.getLimit());
        //2. 执行查询
        List<Users> users=usersMapper.selectByMap(layRequest.getParams());
        //3.创建PageInfo对象
        return new PageInfo<>(users);
    }



    @Override
    public boolean insert(Users users) {
        return usersMapper.insert(users)>0?true : false;
    }

    @Override
    public Users selectById(Integer id) {
        return usersMapper.selectById(id);
    }

    @Override
    public boolean update(Users users) {
        return usersMapper.update(users)>0?true : false;
    }

    @Override
    public boolean delete(Integer id) {
        return usersMapper.delete(id) > 0 ? true : false;
    }

    @Override
    public Users selectByAccount(String account) {
        return usersMapper.selectByAccount(account);
    }


    @Override
    public boolean updateStatus(Users users) {
        return usersMapper.updateStatus(users)>0?true : false;
    }

    @Override
    public boolean updateTime(Users user) {
        return usersMapper.updateTime(user)>0?true : false;

    }

    @Override
    public boolean updatePassword(Users user) {
        return usersMapper.updatePassword(user)>0?true : false;
    }

    @Override
    public List<Users> selectAll() {
        return usersMapper.selectAll();
    }
}